package com.patrick.open.gateway.server.locator;

import com.patrick.open.api.core.event.RemoteRefreshGatewayEvent;
import com.patrick.open.api.core.mapper.Db;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.gateway.route.InMemoryRouteDefinitionRepository;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.ApplicationEventPublisherAware;
import org.springframework.context.ApplicationListener;

/**
 * @author patrick
 * @date 2020/6/12 4:44 下午
 * @Des 自定义动态路由配置
 * 最簡單的事是堅持，最難的事還是堅持
 */
public class JdbcRouteLocator implements ApplicationListener<RemoteRefreshGatewayEvent>, ApplicationEventPublisherAware {
  @Autowired
  private Db db;
  @Autowired
  private ApplicationEventPublisher publisher;

  private InMemoryRouteDefinitionRepository repository;
  /**
   * Set the ApplicationEventPublisher that this object runs in.
   *
   * @param applicationEventPublisher
   */
  @Override
  public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) {

  }

  /**
   * Handle an application event.
   *
   * @param remoteRefreshGatewayEvent 自定义刷新事件
   */
  @Override
  public void onApplicationEvent(RemoteRefreshGatewayEvent remoteRefreshGatewayEvent) {

  }
}
